package com.sunwayhorizo.health.platform.security.persistent;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

import com.sunwayhorizo.health.platform.util.BeanHelper;

@Entity
@TableGenerator(name = "SecurityResourceDataType_IdGenerator", table = "ET_Id_Generator", pkColumnName = "pkColumn", valueColumnName = "valueColumn", pkColumnValue = "SECURITY_RESOURCE_DATA_TYPE_ID",allocationSize=1)
@Table(name = "SECURITY_RESOURCE_DATA_TYPE", schema = "ETS")
public class SecurityResourceDataType implements java.io.Serializable {
	
	@Id
	@GeneratedValue(strategy = GenerationType.TABLE, generator = "SecurityResourceDataType_IdGenerator")
	@Column(name = "RESOURCE_TYPE_ID", unique = true, nullable = false, length = 32)
	private String resourceTypeId;
	
	@ManyToOne(cascade = {CascadeType.PERSIST,CascadeType.MERGE})
	@JoinColumn(name = "RESOURCE_ID")
	private SecurityResource resource;
	
	@ManyToOne(cascade = {CascadeType.PERSIST,CascadeType.MERGE})
	@JoinColumn(name = "DATA_TYPE_ID")
	private SecurityDataType dataType;

	public SecurityResourceDataType() {
	}

	public SecurityResourceDataType(String resourceTypeId) {
		this.resourceTypeId = resourceTypeId;
	}

	public SecurityResourceDataType(String resourceTypeId,
			SecurityResource resource, SecurityDataType dataType) {
		this.resourceTypeId = resourceTypeId;
		this.resource = resource;
		this.dataType = dataType;
	}

	public String getResourceTypeId() {
		return this.resourceTypeId;
	}

	public void setResourceTypeId(String resourceTypeId) {
		this.resourceTypeId = resourceTypeId;
	}

	public SecurityResource getResource() {
		return this.resource;
	}

	public void setResource(SecurityResource resource) {
		this.resource = resource;
	}

	public SecurityDataType getDataType() {
		return this.dataType;
	}

	public void setDataType(SecurityDataType dataType) {
		this.dataType = dataType;
	}
	
	@Override
	public String toString() {
		return BeanHelper.toString(this);
	}
}
